package com.example.demo.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.Employee;
import com.example.demo.mapper.EmployeeMapper;
import com.example.demo.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceimpl extends ServiceImpl<EmployeeMapper, Employee> implements EmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public List<Employee> list() {
        return employeeMapper.selectList(null);
    }

    // 实现登录方法
    @Override
    public Employee login(int id, String password) {
        Employee employee = employeeMapper.findById(Integer.valueOf(id));
        if (employee != null && employee.getPassword().equals(password)) {
            return employee;
        }
        return null;
    }
}